package com.springboot2.security.base.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author liucancan
 * @description 路由控制类 同一定义视图访问地址和视图名称
 * @return
 * @date 2018/12/7
 */
@Configuration
public class MvcConfig implements WebMvcConfigurer {

    /**
     * 统一视图控制，简化controller中跳转视图代码
     *
     * @param registry
     * @return void
     * @author liucancan
     * @date 16:15 2018/12/7
     */
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/home").setViewName("home");
        registry.addViewController("/").setViewName("home");
        registry.addViewController("/hello").setViewName("hello");
        registry.addViewController("/login").setViewName("login");
        registry.addViewController("/registry").setViewName("registry");
    }

}